import Request from '@/libs/request'
import qs from 'qs'

/**web 用户查询设备 检测参数 */
export const uSelectDevParamList = (data: {devId: number}) =>
  Request.get<SimpleParamData[]>('/user/uSelectDevParamList', data)

/**查询用户设备列表 携带计算数据*/
export const uSelectUserDevList = (data: {userId: string | number}) =>
  Request.get<DeviceData[]>('/user/uSelectUserDevList', data)

/**查询用户设备列表 简单设备列表*/
export const selectSimpleDevList = (data: {userId: string | number}) =>
  Request.get<SimpleDeviceData[]>('/user/uSelectMyDevListByUserId', data)

/**获取设备日志类型 */
export const getDevLogType = () => Request.get<Dict[]>('/user/getDevLogType')

/**获取设备日志事件类型 */
export const getDevEventType = () => Request.get<Dict[]>('/user/getDevEventType')

/**用户导出设备日志 */
export const exportDevLog = (data: {
  userId: number | string
  devId?: number
  devLogTypeCode: string
  devEventTypeCode: string
  startDate?: string
  endDate?: string
}) => {
  let param = qs.stringify(data)
  return Request.filePost('/user/export/devLog', param)
}

/**通过字典数据的code查询字典数据 */
export const mSelectItemByCode = (data: {code: string}) =>
  Request.get<Dict>('/user/uSelectItemByCode', data)

/* 查询设备信息的Api */
export const selectDevInfoApi = (data: object) => {
  let param = qs.stringify(data)
  return Request.post('/user/uSelectDevStatusAndSimpleData', param)
}

/* 修改设备名称的Api */
export const editDevNameApi = (data: any) => {
  let param = qs.stringify(data)
  return Request.post('/user/uEditDevName', param)
}
